﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ArtOfTest.WebAii.Silverlight.UI;

namespace SM2DashBoard
{
    public class DashboardCatalogDialog
    {
        public static void selectAddNewBlankDashboard()
        {
            selectCatalog("Add New Dashboard This is a new, blank dashboard for you to start adding panels to.");
        }

        public static void selectCatalog(string strCatalogName)
        {
            Utilities.GlobalObject.SILVERLIGHTAPP.RefreshVisualTrees();
            ListBox lb = Utilities.GlobalObject.SILVERLIGHTAPP.Find.ByName<ListBox>("listCatalogs");
            IList<TextBlock> iList = lb.Find.AllByType<TextBlock>();

            int intCountIList = iList.Count;            
            for (int intIndex = 0; intIndex < intCountIList; intIndex++)
            {
                TextBlock tbItem = iList[intIndex];
                string strTemp = tbItem.Text;
                if (strTemp.Equals(strCatalogName))
                {
                    tbItem.User.Click();
                    break;
                }
            }

            //Click OK
            Button btn = Utilities.GlobalObject.SILVERLIGHTAPP.FindName<Button>("OKButton");
            try
            {
                btn.User.Click();
                System.Threading.Thread.Sleep(Utilities.GlobalConfig.INT_WAIT_INTERVAL_MILISECOND);
            }
            catch { }
        }
    }
}
